package cn.line5.seam.student;

import java.util.List;

import cn.line5.seam.annotations.In;
import cn.line5.seam.annotations.Name;
import cn.line5.seam.annotations.Transaction;
import cn.line5.seam.db.IDGenerator;
import cn.line5.seam.db.PageResult;

@Name("studentService")
/**
 * <h1>LSEAM框架示例业务层实现类</h1>
 * 
 * @author Liu,yandong
 */
public class StudentServiceImpl implements StudentService{
	@In("studentDao")
	private StudentDao studentDao;
	
	public List<StudentVo> getList(){
		return this.studentDao.getList();
	}
	
	public PageResult<StudentVo> getPageList(String currentPage){
		return this.studentDao.getPageList(currentPage);
	}
	
	public StudentVo getStudent(String id){
		return this.studentDao.getStudent(id);
	}
	
	public StudentVo getStudentVo(StudentVo studentVo){
		return this.studentDao.getStudentVo(studentVo);
	}
	
	public boolean saveStudent(StudentVo vo){
		if(vo.getStudentId() != null){
			return this.studentDao.modifyStudent(vo);
		}else{
			vo.setStudentId(IDGenerator.UUID());
			return this.studentDao.insertStudent(vo);
		}
	}

	public StudentVo loginStudent(String loginAccount,String loginPassword){
		return this.studentDao.loginStudent(loginAccount,loginPassword);
	}
	@Transaction
	public boolean deleteStudent(String[] ids){
		boolean t = true;
		for(String id : ids){
			t &= this.studentDao.deleteStudent(id);
		}
		return t;
	}

}
